﻿@model string

<script id="application_menu_template" type="text/x-jquery-tmpl">
	<div class="application_menu">
		<div class="menu_items_container">
			{{each(itemIndex, item) MenuItems}}
				{{tmpl(item) "#menu_item_template"}}
			{{/each}}
		</div>
	</div>
</script>

<script id="menu_item_template" type="text/x-jquery-tmpl">
	<div class="menu_item" tooltip="${Description}" url="${Url}">
		${Title}
		{{if ChildActions}}
			<div class="submenu_items_container">
				{{each(subitemIndex, subitem) ChildActions}}
					{{tmpl(subitem) "#submenu_item_template"}}
				{{/each}}
			</div>
		{{/if}}
	</div>
</script>

<script id="submenu_item_template" type="text/x-jquery-tmpl">
	<div class="submenu_item" tooltip="${Description}" url="${Url}">
		${Title}
	</div>
</script>

<script type="text/javascript">
	var applicationMenuDataSource = new OcenyOpisowe.Client.Data.JsonActionResultDataSource("@Model");

	var applicationInstance = OcenyOpisowe.Client.Application.get_instance();

	var applicationMenu = new OcenyOpisowe.Client.Controls.MenuControl();

	applicationMenu.setMenuTemplate("application_menu_template");
	applicationMenu.setMenuItemsSelector(".menu_item");
	applicationMenu.setMenuSubitemsSelector(".submenu_item");
	applicationMenu.setDataSource(applicationMenuDataSource);

	applicationInstance.setApplicationMenu(applicationMenu);
	
	applicationMenu.dataBind();
</script>